package com.youlu.campus.entity.ca;

import com.youlu.campus.base.base.EntityBase;
import com.youlu.campus.entity.english.ScoreMappingLevel;
import lombok.Data;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.List;


/**
 * 用户参与活动获得证书
 */
@Data
@Document(collection = "user_ca")
@CompoundIndexes({
        @CompoundIndex(name = "user_ca_comIdx", def = "{'userId':1,'caType':1," +
                "'caLevel':1,'activityId':1}", unique = true)
})
public class UserCa extends EntityBase {
    @Indexed
    private String activityId;
    private String activityName;
    /**
     * 用户姓名
     */
    private String name;
    @Indexed
    private String userId;

    private String mobile;

    private String universityId;

    private String universityName;

    private String grade;

    private Double score=0D;
    /**
     * 证书类型
     */
    private String caType;

    /**
     * 证书等级
     */
    @Indexed
    private String caLevel;
    /**
     * 活动证书配置ID
     */
    @Indexed
    private String certificateActivityConfigId;

    private String certificateName;
    /**
     * 备注
     */
    private String comments;
    /**
     * 货币类型,1:数字人民币,2:人民币,3:积分,4:会员权益,5:以物换物,6:免费
     */
    private String moneyType = "2";
    /**
     * 价格
     */
    private Integer price;
    /**
     * 是否已经领取
     */
    @Transient
    private Boolean recieved = Boolean.FALSE;
    /**
     * 业务类型:qa:答题,invite:邀请,ad:看广告,ganwu:提交感悟
     */
    private String taskBizType ="qa";

    private String appId;

    private String platform;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;

        if (o == null || getClass() != o.getClass()) return false;

        UserCa userCa = (UserCa) o;

        return new EqualsBuilder()
                .append(activityId, userCa.activityId)
                .append(userId, userCa.userId)
                .append(caType, userCa.caType)
                .append(caLevel, userCa.caLevel)
                .isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37)
                .append(activityId)
                .append(userId)
                .append(caType)
                .append(caLevel)
                .toHashCode();
    }
}
